package com.nice.demo;

import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class EventActivity extends AppCompatActivity {
    private TextView mTextView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_event);
        mTextView = (TextView) findViewById(R.id.text_tv);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
       int toolType =  event.getToolType(0);
        if(toolType == MotionEvent.TOOL_TYPE_FINGER){
            mTextView.setText("手指触摸");
        }else if(toolType == MotionEvent.TOOL_TYPE_STYLUS) {
            mTextView.setText("手写笔触摸");
        }else {
            mTextView.setText("其他");
        }
        return super.onTouchEvent(event);
    }
}
